<?php
namespace App\Services\Admin;

use Facades\ {
    App\Repositories\Eloquent\AwardRepository,
    App\Repositories\Eloquent\AwardCategoryRepository,
    Yajra\DataTables\Html\Builder
};
use App\Repositories\Traits\DatatableActionButtonTrait;
use DataTables;
use Exception;

class AwardService {
	
	use DatatableActionButtonTrait;

	protected $module = 'award';

	protected $indexRoute = 'award.index';

	protected $createRoute = 'award.create';

	protected $showRoute = 'award.show';

	protected $editRoute = 'award.edit';

	protected $destroyRoute = 'award.destroy';

	/**
	 * datatable数据
	 * @author yinni
	 * @date   2018-06-25晚
	 * @return [type]     [description]
	 */
	public function ajaxData()
	{
		$awards_data =  AwardRepository::all()->toArray();
		return Datatables::of($awards_data)->make(true);
	}

	/**
	 * datatable数据
	 * @author yinni
	 * @date   2018-06-27晚
	 * @return [type]     [description]
	 */
	public function categoryData() {
		$categoryData = AwardCategoryRepository::all()->toArray();
		return Datatables::of($categoryData)->make(true);
	}

	/**
	 * 重写datatable action按钮
	 * @author yinni
	 * @date   2017-11-06
	 * @param  [type]     $id [description]
	 * @return [type]         [description]
	 */
	public function getActionButtonAttribute($id)
	{
		return $this->getShowActionButtion($id).
				$this->getEditActionButton($id).
				$this->getDestroyActionButton($id);
	}

	// 修改当前上传的获奖信息
	public function edit($id) {
		
	}
	
}